<template>
  <v-card class="main-body">
    <v-container>
      <div style="margin: 0 auto; width: 400px">
        <v-row>
          <v-text-field v-model="username" label="账号"></v-text-field>
        </v-row>
        <v-row>
          <v-text-field
            v-model="password"
            label="密码"
            type="password"
          ></v-text-field>
        </v-row>
        <v-row style="text-align: center">
          <v-btn depressed color="primary" @click="login()" class="btn-login">
            登录
          </v-btn>
        </v-row>
      </div>
    </v-container>
  </v-card>
</template>

<script>
export default {
  props: ["username"],
  data() {
    return {
      username: "",
      password: "",
    };
  },
  methods: {
    login() {
      window.localStorage.setItem("username", JSON.stringify(this.username));
      window.localStorage.setItem("password", JSON.stringify(this.password));
      this.$router.replace("/B");
    },
  },
};
</script>

<style>
.main-body {
  padding: 50px 0;
}
.btn-login {
  margin: 0 auto;
}
</style>
